<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.org/ui" xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
</h:head>
<h:body>
	<ui:composition template="template.xhtml">

		<ui:define name="title">mehmet emmy</ui:define>
		<ui:define name="body">
			<c:if test="${sessionScope.currentKullanici.grup != 2}">
				<script language="javascript">
                    	alert("bu sayfaya erişim yetkiniz yoktur.")
    					redirectPage();
	  	 			</script>
			</c:if>	
			<h:form enctype="multipart/form-data" id="urunislemForm">
				<c:choose>
					<c:when test="${AygitBean.selectedAygitObject != null &amp;&amp;
					AygitBean.selectedAygitObject.aygit.sirketprofil.firmaid==SirketprofilBean.currentSirketpro.firmaid}">
						<p:commandButton id="backButton" value="Geri Dön"
							icon="ui-icon-search"
							actionListener="#{AygitBean.deleteSelectedAygit}"
							update=":urunislemForm" />	
																
						<c:choose>											
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='BELLEK'}" >
								<c:choose>
									<c:when test="#{AygitBean.edit==true}">
										<ui:include src="bellekIslem.xhtml" />
									</c:when>
									<c:otherwise>
										<ui:include src="bellekDetails.xhtml" />
									</c:otherwise>
								</c:choose>
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='BUZDOLABI'}">
								<c:choose>
									<c:when test="#{AygitBean.edit==true}">
										<ui:include src="buzdlbIslem.xhtml" />
									</c:when>
									<c:otherwise>
										<ui:include src="buzdlbDetails.xhtml" />
									</c:otherwise>
								</c:choose>								
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='KLIMA'}">
								<c:choose>
									<c:when test="#{AygitBean.edit==true}">
										<ui:include src="klimaIslem.xhtml" />
									</c:when>
									<c:otherwise>
										<ui:include src="klimaDetails.xhtml" />
									</c:otherwise>
								</c:choose>
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='MP3IPOD'}">
								<c:choose>
									<c:when test="#{AygitBean.edit==true}">
										<ui:include src="mp3ipodIslem.xhtml" />
									</c:when>
									<c:otherwise>
										<ui:include src="mp3ipodDetails.xhtml" />
									</c:otherwise>
								</c:choose>
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='TELEFON'}">
								<c:choose>
									<c:when test="#{AygitBean.edit==true}">
										<ui:include src="telIslem.xhtml" />
									</c:when>
									<c:otherwise>
										<ui:include src="telDetails.xhtml" />
									</c:otherwise>
								</c:choose>
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='TV'}">								
								<c:choose>
									<c:when test="#{AygitBean.edit==true}">
										<ui:include src="tvIslem.xhtml" />
									</c:when>
									<c:otherwise>
										<ui:include src="tvDetails.xhtml" />
									</c:otherwise>
								</c:choose>
							</c:when>
							<c:otherwise>
								Hata oluştu
							</c:otherwise>
						</c:choose>		
									
					</c:when>
					<c:otherwise>

						<p:dataTable id="urunAramaTable" var="urun"
							value="#{AygitBean.aygitlar}" widgetVar="urunlerTable"
							resizableColumns="true"
							emptyMessage="No product found with given criteria"
							rowKey="#{urun.aygitid}"
							selection="#{AygitBean.selectedAygitObject}"
							selectionMode="single" paginator="true" rows="10" liveScroll="true">							

							<f:facet name="header">
								<p:outputPanel>
									<h:outputText value="Search all fields:" />
									<p:inputText id="globalFilter" onkeyup="urunlerTable.filter()"
										style="width:150px" />
								</p:outputPanel>
							</f:facet>

							<p:column id="sirketAdColumn"
								filterBy="#{urun.sirketprofil.firmaAd}" headerText="Firma Adı"
								footerText="startsWith">
								<h:outputText value="#{urun.sirketprofil.firmaAd}" />
							</p:column>

							<p:column id="aygitTuruColumn" filterBy="#{urun.aygit.aygitTuru}"
								headerText="Aygıt Türü" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.aygitTuru}" />
							</p:column>

							<p:column id="modelColumn" filterBy="#{urun.aygit.model}"
								headerText="Model" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.model}" />
							</p:column>

							<p:column id="markaColumn" filterBy="#{urun.aygit.marka}"
								headerText="Marka" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.marka}" />
							</p:column>
							 <f:facet name="footer">
								<p:menuButton value="Yeni Ürün Ekle">  
        							<p:menuitem value="Bellek" action="#{BelleklerBean.viewNew}" 
            							icon="ui-icon-star" update=":urunislemForm" />  
            						<p:menuitem value="Buzdolabı" action="#{BuzdolabiBean.viewNew}" 
            							icon="ui-icon-star" update=":urunislemForm" />
            						<p:menuitem value="TV"  action="#{TvBean.viewNew}" 
            							icon="ui-icon-star" update=":urunislemForm" />
            						<p:menuitem value="Klima" action="#{KlimaBean.viewNew}" 
            							icon="ui-icon-star" update=":urunislemForm" />
            						<p:menuitem value="Mp3Ipod" action="#{Mp3ipodBean.viewNew}" 
            							icon="ui-icon-star" update=":urunislemForm" />
            						<p:menuitem value="Telefon" action="#{TelefonBean.viewNew}" 
            							icon="ui-icon-star" update=":urunislemForm" />
    							</p:menuButton> 
    						</f:facet>
    						<f:facet name="footer">
    							<p:commandButton value="Update" update=":urunislemForm" 
	             					action="#{AygitBean.editAygit}" icon="ui-icon-arrowrefresh-1-w" />
             				</f:facet>
             				<f:facet name="footer">
             					<p:commandButton value="Delete" update=":urunislemForm"  icon="ui-icon-close" />
             				</f:facet>
						</p:dataTable>							
						
					</c:otherwise>
				</c:choose>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>